Attribute VB_Name = "Module1"
Public Type TYPE_ITEM
    path As String
    time As Long
End Type

Public iList() As TYPE_ITEM
Public iList_Count As Integer

'Public iList() As Integer


Public Sub Read_List()
    Open "dsu.cfg" For Binary As #1
    Dim item_count As Integer
    Get #1, 1, item_count
    
    If item_count > 0 Then
        ReDim iList(item_count - 1)
        Get #1, LenB(item_count) + 1, iList
        
    End If
    
    iList_Count = item_count
    Close #1
End Sub

Public Sub Save_List()
    Open "dsu.cfg" For Binary As #1
    Dim item_count As Integer

   item_count = iList_Count

   
    Put #1, 1, item_count
    
    If item_count > 0 Then
       Put #1, LenB(item_count) + 1, iList
    End If
    
    
    Close #1
End Sub

Public Sub Remove_Item(ByVal index As Integer)

    Dim list_end As Integer
    
    list_end = UBound(iList)

    If index <> list_end Then
        For i = index To list_end - 1
            iList(i) = iList(i + 1)
        Next i
    ElseIf index > list_end Then
        Exit Sub
    End If
    ReDim Preserve iList(list_end - 1)
    iList_Count = UBound(iList) + 1
End Sub

Public Sub Insert_Item(ByVal index As Integer, ByRef item As TYPE_ITEM)
    Dim list_end As Integer
    
    list_end = iList_Count - 1

    ReDim Preserve iList(iList_Count)
    If index > list_end Then
        index = list_end + 1
    Else
        For i = list_end + 1 To index + 1 Step -1
            iList(i) = iList(i - 1)
        Next i
    End If
    
    iList(index) = item
    iList_Count = UBound(iList) + 1
    
End Sub

Public Sub Add_Item(ByRef item As TYPE_ITEM)
    Dim list_end As Integer
    
    list_end = iList_Count - 1

    Dim index As Integer
    If list_end < 0 Then
        index = 0
    Else
    
        For i = 0 To list_end
            If item.time >= iList(i).time Then
                index = i + 1
            End If
        Next i
    End If
    Insert_Item index, item
    
End Sub


